# ----记账本管理系统（Json版）-----
# 项目需求：
# 包含以下功能：
# 1.初始化记账本数据
#     时间                      项目      分类    金额
#     2021/8/21 09:00:00      工资      收入      20000
#     2021/8/21 09:00:00      聚餐      支出      -200
# 2.读取json数据
# 3.写入json数据
# 4.显示账单（显示总支出金额，总收入金额，结余金额
# 5.写入账单（时间按照格式显示
import json


def read_book(path):
    with open(path, mode='r', encoding='utf-8') as f:
        data = json.load(f)
    return data


def write_data(data_list, path):
    with open(path, mode='w', encoding='utf-8') as f:
        json.dump(data_list, f, ensure_ascii=False)


if __name__ == '__main__':
    path = r'account_book.json'
    print(read_book(path))
    # new_list = [
    #     {"时间": "2021/8/21 09:00:00", "项目": "工资", "分类": "收入", "分类": "20000"},
    #     {"时间": "2021/8/21 09:00:00", "项目": "聚餐", "分类": "支出", "分类": "-200"}
    # ]
    # write_data(new_list, path)
